Gradients for Path Fills
A
gradient
is a fill that contains continuous fades from one color to another. Unlike QuickDraw GX, which supports gradient fills only for bitmaps, QuickTime supports gradient fills for the paths used for QuickTime vectors.
There are two types of gradients: linear, in which the fade begins at one point on a line and ends at another, and circular, in which the fade begins at the center of a circle and ends at the circumference.
Figure 56
illustrates a white-to-black, left-to-right linear gradient, and
Figure 57
illustrates a white-to-black circular gradient.
Figure 56
A linear gradient
Figure 57
A circular gradient
To enable or disable gradient fills and to specify the attributes of gradients, you add atoms to the vector data stream, as described in
"Using QuickTime Vectors"
:
-
You specify the type of gradient (either linear or circular) with a
kCurveGradientTypeAtom
atom.
-
For linear gradients, you can specify the direction in which the gradient is drawn with a
kCurveGradientAngleAtom
atom. You specify this direction with an angle: for example, 0.0 specifies a top-to-bottom gradient, 90.0 specifies a right-to-left gradient, 180.0 specifies a bottom-to-top gradient, and 270.0 specifies a left-to-right gradient.
-
For circular gradients, you can specify the radius of the gradient with a
kCurveGradientRadiusAtom
atom.
-
You specify the colors for gradients with a
kCurveGradientRecordAtom
atom. A gradient must have at least two colors, for the beginning and end, but it can also any number of intermediate colors. Each color is specified by a
GradientColorRecord
structure. You can also add a
kCurveGradientRecordAtom
atom without data to disable gradient fills.
-
You can specify an offset for gradients with a
kCurveGradientOffsetAtom
atom. For circular gradients, this specifies the top left offset from the path being drawn. For linear gradients, it is the offset from the center of the rotated gradient line.
For complete descriptions of these atoms and their default values, see
"Vector QT Atom Container"
.
© 1999 Apple Computer, Inc.| Previous | Chapter Contents | Chapter Top | Next |